package com.pefis.view;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.iotimc.attendancesystem.R;


public class LoadingDialog {
LVCircularRing mLoadingView;
Dialog mLoadingDialog;

public LoadingDialog(Context context,String msg) {
    // 首先得到整个View
    View view = LayoutInflater.from(context).inflate(
            R.layout.loading_dialog_view, null);
    // 获取整个布局
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.dialog_view);
    // 页面中的LoadingView
    mLoadingView = (LVCircularRing) view.findViewById(R.id.lv_circularring);
    // 页面中显示文本
    TextView loadingText = (TextView) view.findViewById(R.id.loading_text);
    // 显示文本
    loadingText.setText(msg);
    // 创建自定义样式的Dialog
    mLoadingDialog = new Dialog(context, R.style.loading_dialog);
    // 设置返回键无效
    mLoadingDialog.setCancelable(true);
    mLoadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
}

public void show(){
	Log.i("hwwlog", "loading show·····");
    mLoadingDialog.show();
    mLoadingView.startAnim();
}

public void dismiss(){
    if (mLoadingDialog!=null) {
    	Log.i("hwwlog", "loading dismiss·····");
        mLoadingView.stopAnim();
        mLoadingDialog.dismiss();
        mLoadingDialog=null;
    }
}
}